<template>
	<view>
		<view class="cu-bar bg-white margin-top">
			<view class="action"><text class="cuIcon-title text-blue"></text>评论内容</view>
		</view>
		<view class="bg-white margin-top">
			<textarea placeholder="请输入评论内容" class="input border" v-model="comment.content"></textarea>
		</view>
		<view class="bottom" @tap="sumbmit()">提交评论</view>
		<view class="cu-load load-modal" v-if="isLoading">
			<view class="cuIcon-emojifill text-orange"></view>
			<view class="gray-text">{{loadMoreDefalutText}}</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
				return {
					comment:{
						avatarUrl:'',
						memberId:0,
						content:'',
						hid:'',
						wechaname:'',
						parentId:null
						
					}
					
			};
		},
		onLoad(option){
			this.comment.hid = option.id;
			this.loadUserInfo();
		},
		methods: {
			loadUserInfo(){
				uni.getStorage({
					key: 'UserInfo',
					success: (res)=>{
						if(!res.data){
							uni.showModal({
								content: '请先登陆!',
								showCancel: false
							});
							uni.navigateBack({
							}) ;
						}
						debugger;
						this.comment.memberId=res.data.id;
						this.comment.avatarUrl=res.data.avatarUrl;
						this.comment.wechaname=res.data.nickName;
					},
					fail:(e)=>{
						uni.showModal({
							content: '请先登陆!',
							showCancel: false,
							success:function(){
								uni.navigateBack({
								}) ;
							}
						});
					}
				});
			},
			sumbmit(){
				var me=this;
				uni.request({
					url: me.$rootUrl + '/Comment/Create',
					data: me.comment,
					method: 'POST',
					success(res) {
						if (res.data.success) {
							uni.showModal({
								content: '提交成功!',
								showCancel: false
							});
							uni.navigateBack({
							})
						} else {
							uni.showModal({
								content: '服务器错误!',
								showCancel: false
							});
						}
					},
					fail() {
						me.isLoading = false;
						me.loadMoreText = me.connectionFailText;
						uni.showModal({
							content: me.connectionFailText,
							showCancel: false
						});
					}
				});
			}
		}
	}
</script>


<style>
	.bottom{
		position: fixed;
		bottom:0;
		background-color: #007AFF;
		padding: 10px 0;
		width:100%;
		font-size: 45upx;
		text-align: center;
		color:white;
	}
</style>
